-
Notifications
You must be signed in to change notification settings - Fork 853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make rand an optional dependency #674
Conversation
- name: Build arrow crate | ||
run: | | ||
export CARGO_HOME="/github/home/.cargo" | ||
export CARGO_TARGET_DIR="/github/home/target" | ||
cd arrow | ||
cargo build --features=js --target wasm32-unknown-unknown | ||
cargo build --no-default-features --features=csv,ipc,simd --target wasm32-unknown-unknown | ||
cargo build --no-default-features --features=csv,ipc,simd --target wasm32-wasi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specifically for wasm32-wasi
there is no real need to exclude test dependencies so cargo build --features=simd --target wasm32-wasi
or cargo build --target wasm32-wasi
also work. However, I don't see a real reason to include it.
|
||
```toml | ||
[dependencies] | ||
arrow = { version = "5.0", default-features = false, features = ["js"] } | ||
arrow = { version = "5.0", default-features = false, features = ["csv", "ipc", "simd"] } | ||
``` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
side note
When compiling to wasm32-wasi
you can also enable the prettyprint
feature if you patch prettytable-rs
in your Cargo.toml
:
[patch.crates-io]
prettytable-rs = { git = "https://github.com/phsym/prettytable-rs", branch = "master"}
This is mentioned in polars but I'm not sure if this fits the arrow README so I didn't include it. The arrow2 project recently changed to comfy-table because prettytable-rs is not maintained (see jorgecarleitao/arrow2#251). I don't think that comfy-table compiles to wasm32-wasi but that's minor for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codecov Report
@@ Coverage Diff @@
## master #674 +/- ##
=======================================
Coverage 82.42% 82.43%
=======================================
Files 168 168
Lines 47250 47326 +76
=======================================
+ Hits 38948 39015 +67
- Misses 8302 8311 +9
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyone know what's the reason for including test_utils
as the one of the default features?
Because |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, minor change suggested
|
||
```toml | ||
[dependencies] | ||
arrow = { version = "5.0", default-features = false, features = ["js"] } | ||
arrow = { version = "5.0", default-features = false, features = ["csv", "ipc", "simd"] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't clearly articulate what's happening, compared to what's being changed. How about:
"In order to compile Arrow for wasm32-unknown-unknown
you will need to disable default features, then include the desired features, but exclude test dependencies (the test_utils
feature). For example, use this snippet in your Cargo.toml
:"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated using your suggested text
Closes apache#671 Signed-off-by: roee88 <[email protected]>
@@ -59,11 +59,13 @@ println!("{:?}", array.value(1)); | |||
|
|||
## Building for WASM | |||
|
|||
In order to compile Arrow for Web Assembly (the `wasm32-unknown-unknown` WASM target), you will likely need to turn off this crate's default features and use the `js` feature. | |||
Arrow can compile to WebAssembly using the `wasm32-unknown-unknown` and `wasm32-wasi` targets. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI wasm32-unknown-emscripten
is not supported because of chronotope/chrono#519
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can accommodate it when there's demand
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @roee88
It might be worth adding / updating the WASM test: https://github.com/apache/arrow-rs/blob/master/.github/workflows/rust.yml#L294-L335 to ensure whatever target you are using continues to work / we don't mess it up with other dependencies. (update I see this was already done)
@nevi-me / @houqp / @roee88 -- do you think this is a change that we should include in arrow-rs
5.2.0 (I plan to create the release candidate this Thursday or Friday) or should we wait for arrow-rs 6.0.0?
# not the core arrow code itself. Be aware that `rand` must be kept as | ||
# an optional dependency for supporting compile to wasm32-unknown-unknown | ||
# target without assuming an environment containing JavaScript. | ||
test_utils = ["rand"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
||
```toml | ||
[dependencies] | ||
arrow = { version = "5.0", default-features = false, features = ["js"] } | ||
arrow = { version = "5.0", default-features = false, features = ["csv", "ipc", "simd"] } | ||
``` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The feature was removed in PR apache#674, but the feature list in the README wasn't updated
The feature was removed in PR #674, but the feature list in the README wasn't updated
Can drop this after rebase on commit fc04931 "Make rand an optional dependency (apache#674)", first released in 6.0.0
Can drop this after rebase on commit fc04931 "Make rand an optional dependency (apache#674)", first released in 6.0.0
Can drop this after rebase on commit fc04931 "Make rand an optional dependency (apache#674)", first released in 6.0.0
Can drop this after rebase on commit fc04931 "Make rand an optional dependency (apache#674)", first released in 6.0.0
Can drop this after rebase on commit fc04931 "Make rand an optional dependency (apache#674)", first released in 6.0.0
Can drop this after rebase on commit fc04931 "Make rand an optional dependency (apache#674)", first released in 6.0.0
Which issue does this PR close?
Closes #671
Rationale for this change
Support wasm32-unknown-unknown target in environments without JavaScript.
What changes are included in this PR?
rand
to be an optional dependencyrand
as a dev dependencyAre there any user-facing changes?
Instructions for compiling to wasm32-unknown-unknown changed